/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package manager;
import Entity.User;
import iface.IManager;
import java.util.ArrayList;
/**
 *
 * @author BinhNV_A04911
 */
public class UserManager  implements IManager<User>{
    private ArrayList<User> userList;

    public UserManager(){
        this.userList=new ArrayList<User>();
    }

    public boolean add(User obj) {
       return this.userList.add(obj);
    }

    public boolean remove(User obj) {
       return this.userList.remove(obj);
    }

    public User replace(int index, User obj) {
        return this.userList.set(index, obj);
    }

    public int size() {
        return this.userList.size();
    }

    public User get(int index) {
       return this.userList.get(index);
    }

    public User getById(int id) {
       for(User objUser:this.userList){
           if(Integer.valueOf(objUser.getUsername())==id){
               return objUser;
           }
       }
       return null;
    }

    public User getByName(String name) {
         for(User obj:this.userList){
           if(obj.equals(obj)){
               return obj;
           }
       }
       return null;
    }

    public void setVisible(User obj, boolean value) {
        for(User objUser:this.userList){
            if(objUser.equals(objUser.getUsername())){
                objUser.setStatus(value);
                break;
            }
        }
    }

}
